class Storage {
  get(type, name) {
    let _data = {}
    if (type === 'session') {
      _data = sessionStorage.getItem(name)
    } else {
      _data = localStorage.getItem(name)
    }

    return JSON.parse(_data)
  }
  set(type, key, data) {
    const _data = JSON.stringify(data)
    if (type === 'session') {
      sessionStorage.setItem(key, _data)
    } else {
      localStorage.setItem(key, _data)
    }
  }
  remove(type, name) {
    if (type === 'session') {
      sessionStorage.removeItem(name)
    } else {
      localStorage.removeItem(name)
    }
  }
}

module.exports = new Storage()
